package com.imjohn.service;

import com.imjohn.entity.Aticle;
import com.imjohn.mapper.AticleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
 * @author zhangwei
 * @date 2021-07-21 下午 4:41
 */
@Service
public class AticleService {
    @Autowired
    AticleMapper aticleMapper;
    /*添加文章*/
    public int AddAticle ( Aticle aticle ) {
        return aticleMapper.AddAticle(aticle);
    }
    /*根据id删除文章*/
    public int DelAticleById ( int aticleId ) {
        return aticleMapper.DelAticleById(aticleId);
    }
    /*修改文章*/
    public int UpdateAticle ( Aticle aticle ) {
        return aticleMapper.UpdateAticle(aticle);
    }

    /*根据用户查询文章*/
    public List<HashMap> GetAticle ( String userName ) {
        return aticleMapper.GetAticle(userName);
    }

    /*根据用户id查询文章*/
    public List<HashMap> getAticleById ( int id ) {
        return aticleMapper.getAticleById(id);
    }
    /*根据用户id查询文章*/
    public Aticle getAticleById2 ( int id ) {
        return aticleMapper.getAticleById2(id);
    }

    public List<HashMap> GetAllAticle () {
        //查询所有的用户信息
        return aticleMapper.GetAllAticle();
    }
    /*根据文章类型查询文章*/
    public List<HashMap> GetTypeAticle ( String aticleType ) {
        return aticleMapper.GetTypeAticle(aticleType);
    }
    /*阅读量加1*/
    public int addReadNum(int aticleId) {
        return aticleMapper.addReadNum(aticleId);
    }
    /*点赞量加1*/
    public int addGoodNum(int aticleId) {
        return aticleMapper.addGoodNum(aticleId);
    }
    /*点赞量减1*/
    public int subGoodNum(int aticleId) {
        return aticleMapper.subGoodNum(aticleId);
    }
    /*评论加1*/
    public int subCommentNum(int aticleId) {
        return aticleMapper.subCommentNum(aticleId);
    }

}